﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Orbitone.MeetingRooms.Services;
using Orbitone.MeetingRooms.Services.Model;

namespace Orbitone.MeetingRooms.Tests
{
    [TestFixture]
    public class Class1
    {
        string STARTTIME = "08:00:00";
        string ENDTIME = "18:30:00";

        string roomEmail = "boardroom15@orbitone.com";

        private LdapService ldapService;
        private IExchangeService exchangeService;

        [SetUp]
        void RunBeforeAnyTest()
        {
            ldapService = new LdapService();
            exchangeService = new ExchangeService();
        }


        [Test]
        public void Exchange()
        {
            
            var rooms = ldapService.FindRooms();
            var startdate = DateTime.ParseExact(new DateTime(2011, 7, 19).ToString("yyyyMMdd") + "T" + STARTTIME, "yyyyMMddTHH:mm:ss", null);
            var enddate = DateTime.ParseExact(new DateTime(2011, 7, 19).ToString("yyyyMMdd") + "T" + ENDTIME, "yyyyMMddTHH:mm:ss", null);
            var availability = exchangeService.GetAvailability(rooms, startdate, enddate, 30);
        }

        [Test]
        public void ExchangeSaveAppointment()
        {
            var startdate = DateTime.ParseExact(new DateTime(2011, 7, 26, 9, 0,0, DateTimeKind.Unspecified).ToString("yyyyMMddTHH:mm:ss"), "yyyyMMddTHH:mm:ss", null);
            var enddate = DateTime.ParseExact(new DateTime(2011, 7, 26, 10, 0, 0, DateTimeKind.Unspecified).ToString("yyyyMMddTHH:mm:ss"), "yyyyMMddTHH:mm:ss", null);

            var app = new CalendarEventModel()
                          {
                              StartDate = startdate,
                              EndDate = enddate,
                              Mailbox = roomEmail,
                              UserId = "",
                              Subject = "Advance Design Presentation"
                          };

            var itemid = exchangeService.SaveAppointment(app);
        }


        [Test]
        public void ExchangeFindRooms()
        {
            //var rooms = exchangeService.FindRooms();
        }

        [Test]
        public void Ldap()
        {
            var rooms = ldapService.FindRooms();
        }

        [Test]
        public void ExchangeFind()
        {
            var startdate = DateTime.ParseExact(new DateTime(2011, 7, 25).ToString("yyyyMMdd") + "T" + STARTTIME, "yyyyMMddTHH:mm:ss", null);
            var enddate = DateTime.ParseExact(new DateTime(2011, 7, 25).ToString("yyyyMMdd") + "T" + ENDTIME, "yyyyMMddTHH:mm:ss", null);
            //exchangeService.FindAppointment("My NetShowUrl Property value");
        }

        [Test]
        public void ExchangeDelete()
        {
            var startdate = DateTime.ParseExact(new DateTime(2011, 7, 25).ToString("yyyyMMdd") + "T" + STARTTIME, "yyyyMMddTHH:mm:ss", null);
            var enddate = DateTime.ParseExact(new DateTime(2011, 7, 25).ToString("yyyyMMdd") + "T" + ENDTIME, "yyyyMMddTHH:mm:ss", null);
            var appointments = exchangeService.FindAppointments("My NetShowUrl Property value", roomEmail);
            exchangeService.DeleteAppointment(appointments[0].Id, roomEmail);
        }

    }
}
